package com.chis.childcheck;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * 
 * @Description 
 * @Company zwx
 * @author wlj
 * @version 2019年08月14日
 */
public class KafkaCheck {
    public static void main(String[] args) {
        String files = "C:\\Users\\Administrator\\Desktop\\lyg\\warn (4).log";
        String time = "2019-09-10";
        File file1 = new File(files);
        FileReader m = null;
        try {
            m = new FileReader(file1);
        } catch (Exception e) {
            e.printStackTrace();
        }
        BufferedReader reader = new BufferedReader(m);
        List<String> list = new ArrayList<>();
        while (true) {
            String nextline = null;
            try {
                nextline = reader.readLine();
                if (nextline != null && nextline.length() > 8) {
                    if(nextline.startsWith(time)){
                        String msg = nextline.substring(nextline.indexOf("step")+7);
                        if(nextline.contains("step:1")){
                            list.add(msg);
                        } else if(nextline.contains("step:2") && list.contains(msg)) {
                            list.remove(msg);
                        }
                    }
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (nextline == null) break;
        }
        for(String sd : list ){
            System.out.println(sd);
        }

    }


}
